package component.divider;

import component.util.MaterialColors;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class Divider extends JLabel {
    private Color color;
    private int thickness;
    public Divider(Color color, int thickness, int height){
        super();
        this.color = color;
        this.thickness = thickness;
//        this.setBorder(BorderFactory.createLineBorder(color, thickness));
        this.setBorder(new EmptyBorder(thickness + height / 2,0,height / 2,0));

    }

    public Divider(){
        this(MaterialColors.GRAY_700,1,0);
    }

    public Divider(int thickness){
        this(MaterialColors.GRAY_700, thickness, 0);
    }

    public Divider(Color color){
        this(color,1,0);
    }

    @Override
    public void paint(Graphics g) {
        Graphics2D graphics2D = (Graphics2D) g.create();
        graphics2D.setColor(color);
        graphics2D.fillRect(0,0,getWidth(),thickness);
        graphics2D.dispose();
    }
}
